const path = require('path');
const webpack = require('webpack');
const Parame = require('./public/constants');
const packageJson = require('../package.json');
let ReactFamily = ['redux','react', 'react-dom','react-redux','react-router','react-router-redux','redux-devtools-extension','redux-thunk'];
module.exports= {
  entry: {
    [Parame.reactLibraryName]:ReactFamily
  },
  devtool: 'sourcemap',
  cache: false,
  output: {
    path: path.join(Parame.rootPath, 'dll'),
    filename: '[name].dll.js',
    /**
     * output.library
     * 将会定义为 window.${output.library}
     * 在这次的例子中，将会定义为`window.vendor_library`
     */
    library: '[name]'
  },
  plugins:[
    new webpack.DllPlugin({
      /**
       * path
       * 定义 manifest 文件生成的位置
       * [name]的部分由entry的名字替换
       */
      path: path.join(Parame.rootPath, 'dll', '[name]-manifest.json'),
      /**
       * name
       * dll bundle 输出到那个全局变量上
       * 和 output.library 一样即可。
       */
      name: '[name]'
    }),
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': '"production"',//切换为node生产环境
      'process.env.REACT_WEBPACK_ENV':'"dist"'
    }),
    new webpack.optimize.UglifyJsPlugin({
      /*compress: {
        drop_console:false//默认为false; true为删除所有console.*的语句
      },*/
      quote_keys:true,
      max_line_len:1024*1024,//单行最大长度默认32000
      comments: /@@!///默认保留
    }),
    //new webpack.optimize.AggressiveMergingPlugin({moveToParents:true}),//暂时关闭自动合并模块，为了体现分块的效果
    new webpack.NoEmitOnErrorsPlugin()
  ]
};
